﻿
Public Class MysqlTableInfo
    Private ltablename As String
    Private lcolnum As Integer
    Private lnumrow As Long
    Private lcols As New ArrayList
    

    Public Property ColumnsNumbers As Integer
        Get
            Return lcolnum
        End Get
        Set(ByVal value As Integer)
            lcolnum = value
        End Set
    End Property

    Public Property TotalRows As Long
        Get
            Return lnumrow
        End Get
        Set(ByVal value As Long)
            lnumrow = value
        End Set
    End Property

    Public Property TableName As String
        Get
            Return ltablename
        End Get
        Set(ByVal value As String)
            ltablename = value
        End Set
    End Property

    Public Property Columns As ewinsync.MysqlColInfo()
        Get
            Dim test = lcols.ToArray
            Dim t2 As MysqlColInfo()
            ReDim t2(lcols.Count)
            For index = 0 To lcols.Count - 1
                t2(index) = lcols.Item(index)
            Next
            Return t2
        End Get
        Set(ByVal value As ewinsync.MysqlColInfo())
            lcols.AddRange(value)
        End Set
    End Property
    Public Sub addColumn(ByVal col As MysqlColInfo)
        Dim r As MysqlColInfo = getColumn(col.ColumnName)
        If (Not IsNothing(r)) Then
            lcols.Remove(r)
        End If
        lcols.Add(col)
    End Sub
    Public Function getColumn(ByVal colname As String) As MysqlColInfo
        For Each r As MysqlColInfo In lcols
            If (r.ColumnName = colname) Then Return r
        Next
        Return Nothing
    End Function
    Public Sub New(ByVal tbln As String)
        TableName = tbln
    End Sub
    Public Function getcolumnAsString() As String
        Dim cm As String = ""
        For Each r As MysqlColInfo In lcols
            cm = cm + vbTab + vbTab + "  " + r.ColumnName + vbCrLf
        Next
        Return cm
    End Function
End Class
